package cn.xpride.framework.http;

import java.lang.reflect.Method;
import java.util.LinkedHashMap;
import java.util.Map;

import org.smartboot.http.server.HttpRequest;

public class SmartHttpContext {

    static final Map<String, Method> uriMethodMap = new LinkedHashMap<>();
    static final Map<Method, Object> methodObjectMap = new LinkedHashMap<>();

    static String staticDir = null;

    static String classDir = null;

    private final static ThreadLocal<HttpRequest> threadLocal = new InheritableThreadLocal<>();

    /**
     * 设置当前线程的HttpRequest
     * */
    static void currentSet(HttpRequest request){
        threadLocal.set(request);
    }

    /**
     * 移除当前线程的HttpRequest
     * */
    static void currentRemove(){
        threadLocal.remove();
    }

    /**
     * 获取当前线程的HttpRequest
     * */
    public static HttpRequest currentHttpRequest(){
        return threadLocal.get();
    }

    public static String getStaticDir() {
        return staticDir;
    }

    public static String getClassDir() {
        return classDir;
    }
}
